#!/bin/sh /etc/rc.common

START=91
STOP=91

USE_PROCD=1

hwnat_reg(){
	if [ -e "/etc/wireless/l1profile.dat" ]; then
		iflist=$(cat /etc/wireless/l1profile.dat | grep INDEX[0-9]_main_ifname | cut -d= -f2)
		echo "$iflist" | while read line; do
			iwpriv $line set hw_nat_register=1
		done
	fi
}

start_service() {
	config_load hwnat
	local hwnat_en
	config_get_bool hwnat_en global enabled
	if [ "$hwnat_en" = "1" ]; then
		insmod /lib/modules/ralink/hw_nat.ko
		hwnat_reg
	fi
	mknod /dev/hwnat0 c 220 0
}

stop_service() {
	rmmod hw_nat.ko
}